<?php
namespace app\api\controller;
use think\Controller;
use app\api\model\Myevaluation as Myevas;
use think\Request;
use app\api\model\Venue;
use app\api\model\Favorite;
/**
 * 
 * @author sj
 *我的评价
 */
class Myevaluation extends Co{
    //我的评价列表
    private  static  $MyevaModel;
    private  static  $VeModel;
    private  static  $FModel;
    
//     public function __construct(){
//         if(!self::$MyevaModel instanceof self){
//             self::$MyevaModel=new Myevas();
//         }
//         if(!self::$VeModel instanceof  self){
//             self::$VeModel=new Venue();
//         }
//         if(!self::$FModel instanceof self){
//             self::$FModel=new Favorite();
//         }
//     }
    protected $beforeActionList = [
               'berefo'
              ];
    
    public function berefo(){
        if(!self::$MyevaModel instanceof self){
            self::$MyevaModel=new Myevas();
        }
        if(!self::$VeModel instanceof  self){
            self::$VeModel=new Venue();
        }
        if(!self::$FModel instanceof self){
            self::$FModel=new Favorite();
        }
    }
    public function selectLists(){
      //$res= self::$MyevaModel->selectLists(5);
     //dump($res);
     //return view('look');
     //我的收藏 查询的是收藏表 的评价是查询的是评价表 
     $user_id=session('user_id');
    
     $res=self::$MyevaModel->selectInfo($user_id);
     //dump($res);
     //再进行查询我的收藏
     $result=self::$FModel->selectLists($user_id);
     $data_new=[];
     $data_new['evat']=$res;
     $data_new['favorite']=$result;
     $res=null;
     $result=null;
     //dump($data_new);
     return view('my-coll',array('data'=>$data_new));
    }
    /*
     * 健身易结束开始健身
     */
    public function create(){
        if(Request::instance()->isGet()){
            $where=input('get.');
            $res=self::$VeModel->getItem($where['place_id']);
            $user_id=session('user_id');
            $data_new=[];
            $data_new['info']=$res;
            $data_new['appoint_time']=$where['appoint_time'];
            $data_new['count']=array_to_fe($where['appoint_time']);
            $data_new['riqi']=$where['riqi'];
            //dump($data_new);
            return view('evaluate',array('res'=>$data_new));
            //return view()
        }else{
              // echo json_encode(input('post.'));
              $post_data=input('post.');
              $post_data['user_id']=session('user_id');
              $res=self::$MyevaModel->evate($post_data);
              if($res){
                  ajaxReturn2(1,'评价成功',url('api/Myevaluation/selectLists'));
              }else{
                  ajaxReturn2(0,'评价失败','');
              }
            }
    }
}